All Packages Class Hierarchy This Package Previous Next Index
Class sun.servlet.http.HttpRequest
java.lang.Object
|
+----sun.servlet.http.HttpRequest
- public class HttpRequest
- extends Object
- implements HttpServletRequest
This class represents an HTTP servlet request.
-
authType
- The authentication type for the request.
-
con
- The servlet connection for the request.
-
headers
- The MIME header fields for the request.
-
in
- The input stream for reading request data.
-
keepAlive
- Set to true if the connection should be kept alive.
-
length
- The content length for this request.
-
line
- The request line.
-
params
- The dictionary that represents the name/values pairs
for parameters passed in the request.
-
pathInfo
- The path info for the request.
-
remoteUser
- The remote user for the request.
-
servletPath
- The servlet path for the request.
-
HttpRequest()
- Creates a new HttpRequest object.
-
addAttributeDictionary(Dictionary)
- Stores an attribute dictionary, to be consulted for request
attributes.
-
dump(PrintStream)
- Print debug information.
-
finish()
- Finishes the current request.
-
getAttribute(String)
- Returns an attribute of the request for the specified key name.
-
getAuthType()
- Returns the authentication scheme of the request, or null if none.
-
getContentLength()
- Returns the size of the request entity data, or -1 if not known.
-
getContentType()
- Returns the Internet Media Type of the request entity data, or
null if not known.
-
getDateHeader(String)
- Returns the value of a date header field, or -1 if not found.
-
getHeader(String)
- Returns the value of a header field, or null if not known.
-
getHeaderNames()
- Returns an enumeration of strings representing the header names
for this request.
-
getHeaders()
- Returns the message header for this response.
-
getInputStream()
- Returns an input stream for reading request data.
-
getIntHeader(String)
- Returns the value of an integer header field, or -1 if not found.
-
getKeepAlive()
- Returns true if this connection should be kept alive.
-
getMethod()
- Returns the method with which the request was made.
-
getParameter(String)
- Returns the value of the specified parameter for the request.
-
getParameterNames()
- Returns an enumeration of strings representing the parameter names
for this request.
-
getParameterValues(String)
- Returns the value of the specified parameter for the request.
-
getPathInfo()
- Returns optional extra path information following the servlet path,
but immediately preceding the query string.
-
getPathTranslated()
- Returns extra path information translated to a real file system path.
-
getProtocol()
- Returns the protocol and version of the request as a string of the
form <protocol>/<major version>.<minor version>.
-
getQueryString()
- Returns the query string part of the servlet URI, or null if none.
-
getRealPath(String)
- Applies alias rules to the specified virtual path and returns the
corresponding real path.
-
getRemoteAddr()
- Returns the IP address of the agent that sent the request.
-
getRemoteHost()
- Returns the fully qualified host name of the agent that sent the
request.
-
getRemoteUser()
- Returns the name of the user making this request, or null if not
known.
-
getRequestLine()
- Returns the request line bytes.
-
getRequestPath()
- Returns the request path bytes.
-
getRequestURI()
- Returns the request URI as string.
-
getScheme()
- Returns the scheme of the URL used to make this request, such
as "http" or "https".
-
getServerName()
- Returns the host name of the server that received the request.
-
getServerPort()
- Returns the port number on which this request was received.
-
getServletPath()
- Returns the part of the request URI that refers to the servlet
being invoked.
-
getTotalBytes()
- Returns the total number of bytes for this request.
-
init(ServletConnection)
- Initializes the request using the specified servlet connection.
-
isFullRequest()
- Returns true if this is a full (i.e.
-
isProxyRequest()
- Returns true if this is a proxy request.
-
next()
- Reads the next request from the current connection.
-
reset()
- Resets the servlet request.
-
setAuthType(byte[], int, int)
- Sets the authentication scheme of the request to the specified bytes.
-
setAuthType(String)
- Sets the authentication scheme of the request to the specified String.
-
setHeader(String, String)
- Sets the value of a header field to the specified String.
-
setKeepAlive(boolean)
- Used to indicate whether this connection should be kept alive.
-
setPathInfo(byte[], int, int)
- Sets the path info for the request to the specified bytes.
-
setPathInfo(String)
- Sets the path info for the request to the specified string.
-
setRemoteUser(byte[], int, int)
- Sets the name of the user making this request to the specified bytes.
-
setRemoteUser(String)
- Sets the name of the user making this request to the specified String.
-
setRequest(HttpRequest)
-
-
setServletPath(byte[], int, int)
- Sets the servlet path for the request to the specified bytes.
-
setServletPath(String)
- Sets the servlet path for the request to the specified string.
line
protected HttpRequestLine line
- The request line.
servletPath
protected final MessageString servletPath
- The servlet path for the request.
pathInfo
protected final MessageString pathInfo
- The path info for the request.
remoteUser
protected final MessageString remoteUser
- The remote user for the request.
authType
protected final MessageString authType
- The authentication type for the request.
headers
protected MimeHeaders headers
- The MIME header fields for the request.
in
protected HttpInputStream in
- The input stream for reading request data.
con
protected ServletConnection con
- The servlet connection for the request.
length
protected int length
- The content length for this request.
keepAlive
protected boolean keepAlive
- Set to true if the connection should be kept alive.
params
protected Dictionary params
- The dictionary that represents the name/values pairs
for parameters passed in the request.
HttpRequest
public HttpRequest()
- Creates a new HttpRequest object.
init
public void init(ServletConnection con) throws IOException
- Initializes the request using the specified servlet connection.
- Parameters:
- connect - the servlet connection
- Throws: IOException
- if an I/O error has occurred
next
public boolean next() throws IOException, InvalidRequestException
- Reads the next request from the current connection. Returns true if the
request could be read otherwise returns false if the end of the stream
is reached.
- Throws: IOException
- if an I/O error has occurred
- Throws: InvalidRequestException
- if the request is invalid
finish
public void finish() throws IOException
- Finishes the current request.
reset
public void reset() throws IOException
- Resets the servlet request.
isFullRequest
public boolean isFullRequest()
- Returns true if this is a full (i.e. not HTTP/0.9) request.
isProxyRequest
public boolean isProxyRequest()
- Returns true if this is a proxy request.
getTotalBytes
public int getTotalBytes()
- Returns the total number of bytes for this request.
getHeaders
public MimeHeaders getHeaders()
- Returns the message header for this response.
setKeepAlive
public void setKeepAlive(boolean enable)
- Used to indicate whether this connection should be kept alive.
- Parameters:
- enable - if true then keep connection alive
getKeepAlive
public boolean getKeepAlive()
- Returns true if this connection should be kept alive.
getRequestPath
public MessageBytes getRequestPath()
- Returns the request path bytes.
getRequestLine
public MessageBytes getRequestLine()
- Returns the request line bytes.
setServletPath
public void setServletPath(String s)
- Sets the servlet path for the request to the specified string.
setServletPath
public void setServletPath(byte b[],
int off,
int len)
- Sets the servlet path for the request to the specified bytes.
setPathInfo
public void setPathInfo(String s)
- Sets the path info for the request to the specified string.
setPathInfo
public void setPathInfo(byte b[],
int off,
int len)
- Sets the path info for the request to the specified bytes.
getContentLength
public int getContentLength()
- Returns the size of the request entity data, or -1 if not known.
Same as the CGI variable CONTENT_LENGTH.
getContentType
public String getContentType()
- Returns the Internet Media Type of the request entity data, or
null if not known. Same as the CGI variable CONTENT_TYPE.
getProtocol
public String getProtocol()
- Returns the protocol and version of the request as a string of the
form <protocol>/<major version>.<minor version>.
Same as the CGI variable SERVER_PROTOCOL.
getScheme
public String getScheme()
- Returns the scheme of the URL used to make this request, such
as "http" or "https".
getServerName
public String getServerName()
- Returns the host name of the server that received the request.
Same as the CGI variable SERVER_NAME.
getServerPort
public int getServerPort()
- Returns the port number on which this request was received.
Same as the CGI variable SERVER_PORT.
getRemoteAddr
public String getRemoteAddr()
- Returns the IP address of the agent that sent the request.
Same as the CGI variable REMOTE_ADDR.
getRemoteHost
public String getRemoteHost()
- Returns the fully qualified host name of the agent that sent the
request. Same as the CGI variable REMOTE_HOST.
getInputStream
public ServletInputStream getInputStream() throws IOException
- Returns an input stream for reading request data.
getParameter
public String getParameter(String name)
- Returns the value of the specified parameter for the request. For
example, in an HTTP servlet this would return the value of the
specified query string parameter. This must be used when the
application is sure that there is only one value for the parameter.
For multiple valued parameters, use getParameterValues.
- Parameters:
- name - the parameter name
- Returns:
- the value for the parameter. For multiple values, a comma
separated string of values is returned. Preferred way is to call
getParameterValues for multiple valued parameters.
- See Also:
- getParameterValues
getParameterValues
public String[] getParameterValues(String name)
- Returns the value of the specified parameter for the request. For
example, in an HTTP servlet this would return the value of the
specified query string parameter.
- Parameters:
- name - the parameter name
- Returns:
- an array of values for the passed parameter name. If there are
no values then return null.
getParameterNames
public Enumeration getParameterNames()
- Returns an enumeration of strings representing the parameter names
for this request.
getMethod
public String getMethod()
- Returns the method with which the request was made. The returned
value can be "GET", "HEAD", "POST", or an extension method. Same
as the CGI variable REQUEST_METHOD.
getRequestURI
public String getRequestURI()
- Returns the request URI as string.
getServletPath
public String getServletPath()
- Returns the part of the request URI that refers to the servlet
being invoked. Analogous to the CGI variable SCRIPT_NAME.
getPathInfo
public String getPathInfo()
- Returns optional extra path information following the servlet path,
but immediately preceding the query string. Returns null if not
specified. Same as the CGI variable PATH_INFO.
getPathTranslated
public String getPathTranslated()
- Returns extra path information translated to a real file system path.
Returns null if no extra path information was specified or translated
path was unavailable. Same as the CGI variable PATH_TRANSLATED.
getRealPath
public String getRealPath(String path)
- Applies alias rules to the specified virtual path and returns the
corresponding real path.
getQueryString
public String getQueryString()
- Returns the query string part of the servlet URI, or null if none.
Same as the CGI variable QUERY_STRING.
setRemoteUser
public void setRemoteUser(String s)
- Sets the name of the user making this request to the specified String.
- Parameters:
- s - the user name
setRemoteUser
public void setRemoteUser(byte b[],
int off,
int len)
- Sets the name of the user making this request to the specified bytes.
- Parameters:
- b - the user name bytes
- off - the start offset of the bytes
- len - the length of the bytes
getRemoteUser
public String getRemoteUser()
- Returns the name of the user making this request, or null if not
known. Same as the CGI variable REMOTE_USER.
setAuthType
public void setAuthType(String s)
- Sets the authentication scheme of the request to the specified String.
- Parameters:
- s - the authentication scheme
setAuthType
public void setAuthType(byte b[],
int off,
int len)
- Sets the authentication scheme of the request to the specified bytes.
- Parameters:
- b - the authentication scheme bytes
- off - the start offset of the bytes
- len - the length of the bytes
getAuthType
public String getAuthType()
- Returns the authentication scheme of the request, or null if none.
Same as the CGI variable AUTH_TYPE.
getHeader
public String getHeader(String name)
- Returns the value of a header field, or null if not known.
The case of the header field name is ignored.
- Parameters:
- name - the case-insensitive header field name
setHeader
public void setHeader(String name,
String value)
- Sets the value of a header field to the specified String.
- Parameters:
- name - the header field name
- value - the header field String value
getIntHeader
public int getIntHeader(String name)
- Returns the value of an integer header field, or -1 if not found.
The case of the header field name is ignored.
- Parameters:
- name - the case-insensitive header field name
getDateHeader
public long getDateHeader(String name)
- Returns the value of a date header field, or -1 if not found.
The case of the header field name is ignored.
- Parameters:
- name - the case-insensitive header field name
getHeaderNames
public Enumeration getHeaderNames()
- Returns an enumeration of strings representing the header names
for this request. Some server implementations do not allow headers
to be accessed in this way, in which case this method will return null.
getAttribute
public Object getAttribute(String name)
- Returns an attribute of the request for the specified key name.
- Parameters:
- name - the attribute name
- Returns:
- the attribute value or null if not found
addAttributeDictionary
public void addAttributeDictionary(Dictionary d)
- Stores an attribute dictionary, to be consulted for request
attributes.
dump
public void dump(PrintStream out)
- Print debug information.
setRequest
protected void setRequest(HttpRequest req)
All Packages Class Hierarchy This Package Previous Next Index